package com.jic.product.impl;

import java.lang.Long;
import java.util.List;

import com.jic.product.entity.ProductDescribe;
import com.jic.product.mapper.ProductDescribeMapper;
import com.jic.product.service.ProductDescribeService;
import com.jic.common.base.vo.Page;
import com.jic.common.base.vo.PageResult;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 商品文描表
 *
 * @author :
 * @version : v1.0.0
 * @email :
 * @since : 2020-01-10 07:03:01
 */
@Service
public class ProductDescribeServiceImpl implements ProductDescribeService {

    @Autowired
    private ProductDescribeMapper productDescribeMapper;

    @Override
    public long insert(ProductDescribe productDescribe) {
        long flag = productDescribeMapper.insert(productDescribe);
        return flag;
    }

    @Override
    public long delete(Long id) {
        return productDescribeMapper.delete(id);
    }

    @Override
    public long update(ProductDescribe productDescribe) {
        return productDescribeMapper.update(productDescribe);
    }

    @Override
    public ProductDescribe queryByPrimaryKey(Long id) {
        return productDescribeMapper.queryByPrimaryKey(id);
    }

    @Override
    public List<ProductDescribe> query(ProductDescribe productDescribe) {
        return productDescribeMapper.query(productDescribe);
    }

    @Override
    public PageResult<ProductDescribe> queryPage(ProductDescribe productDescribe, Page pageQuery) {
        //计算下标
        int startIndex = (pageQuery.getStart() - 1) * pageQuery.getLimit();
        List<ProductDescribe> list = productDescribeMapper.queryPage(startIndex, pageQuery.getLimit(), productDescribe);
        long count = productDescribeMapper.queryPageCount(productDescribe);
        PageResult pageResult = new PageResult();
        pageResult.setRows(list);
        pageResult.setTotal(count);
        return pageResult;
    }

    @Override
    public List<ProductDescribe> getProductDescribe(ProductDescribe productDescribe) {
        return productDescribeMapper.getProductDescribe(productDescribe);
    }
}